<?php

/***  DOCUMENTATION LAYER

Last Update: May 2007
	
DESCRIPTION
	brief description of script here
	
NOTES
	3 sections to edit below:
		1. Meta Data
		2. Procedure Block
		3. Function
	
***/

/* -- EDIT THIS SECTION ----------------------------------------------------- */
// Some Meta Data
$page_title = 'PHP Sandbox';
$test_name = 'Simple Test';
$run_procedure = 0;
$run_function = 1;
$num_cycles = 10;		// num of cycles to run function

// Include Files
require_once('../html/navbar.inc.php');

// Navbar Style Settings
$css = <<<CSS

<style type="text/css">

/* kw_navbar settings */
/* note : coordinate outer container (.kw_navbar) padding with a link (.kw_navbar a) padding */
.kw_navbar 
{ 
 width:50%;
 margin:0 auto 8px;
 padding:4px 0px 2px;
 text-align:center;
 font:1em sans-serif;
 background:#eef;
 border:1px solid #ccf; 
}
.kw_navbar ul { margin:0 auto; padding:0; text-align:center; }
.kw_navbar li { display:inline; list-style:none; margin:0; padding:0; }
.kw_navbar a 
{ 
 padding:4px 12px; 
 margin:0 3px; 
 text-decoration:none; 
}
.kw_navbar a:hover { background:#ccd; }
.kw_navbar .active { font-weight:bold; }
</style>

CSS;

/* -- END SECTION ----------------------------------------------------------- */



/* -- NO EDIT --------------------------------------------------------------- */
// Timer
$_tx0 = microtime();
// HEADER
$buffer = "<h1 style='margin:8px 0 0;'>$page_title</h1>";
$buffer .= "<h4 style='margin:0 0 16px;'>$test_name</h4>";	// put script name here
/* -- END SECTION ----------------------------------------------------------- */



/* -- EDIT THIS SECTION ----------------------------------------------------- */
// Procedural Testing

if ( $run_procedure ) 
{
	$buffer .= "<h4 style='margin:0; color:blue;'>Testing in Progess</h4>";
	
	// add code below
}

/* -- END SECTION ----------------------------------------------------------- */



/* -- EDIT THIS SECTION ----------------------------------------------------- */
// Function Test
if ( $run_function )
{
	// navbar array
	$php_self = $_SERVER['PHP_SELF'];
	$base_url = dirname($php_self);
	$NAVBAR_ARRAY = array
	(
		'self' => $php_self,
		'dir' => $base_url,
		'google_code' => 'http://code.google.com',
	);
	
	foreach ( $NAVBAR_ARRAY as $k => $v ) $RAND[] = $k;

	// run function
	$buffer .= "<h2 style='margin:0; color:green;'>Function Test</h2>";	
	while ( $num_cycles )
	{
		$navbar = kw_auto_navbar_list($NAVBAR_ARRAY);
		$buffer .= "<h6 style='margin:0; color:#ccc;'>active url: {$_SERVER['PHP_SELF']}</h6>";
		$buffer .= $navbar;
		$num_cycles--;
		
		// alternate active url
		$new_key = $RAND[array_rand($RAND)];
		$_SERVER['PHP_SELF'] = $NAVBAR_ARRAY[$new_key];		
	}
}

/* -- END SECTION ----------------------------------------------------------- */





/* -- NO EDITING NEEDED BELOW THIS LINE-------------------------------------- */
// output page

// Footer
$_txn = microtime();
$stx = number_format(((substr($_txn,0,9)) + (substr($_txn,-10)) - (substr($_tx0,0,9)) - (substr($_tx0,-10))),4); 
$footer = <<<HTML
<h4 style="margin:0; position:absolute; top:6px; right:6px; font-family:monospace; color:#36f; padding:4px; border:1px solid #36f; font-weight:normal; background:#f3f6ff;">
script completed in $stx s
</h4>
HTML;
$buffer .= $footer;

// Dump Html
$html = <<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<title>PHP Test: $page_title</title>
$css
</head>
<body>
$buffer
</body>
</html>
HTML;

echo $html;

?>
